This will be required in the upcoming version of GJS.
The reference count on ShellGlobal is 2 at this point, because JS holds a
reference due to the "window.global = Shell.Global.get()" line in
ui/environment.js. Therefore, destroy the GjsContext first, then unref
the ShellGlobal object.
Cleaning up ShellGlobal was previously only enabled behind a debug
environment variable, but it should be required now.
https://bugzilla.gnome.org/show_bug.cgi?id=775374
ecode = meta_run ();
- if (g_getenv ("GNOME_SHELL_ENABLE_CLEANUP"))
- {
- g_printerr ("Doing final cleanup...\n");
- g_object_unref (shell_global_get ());
- }
-
+ g_debug ("Doing final cleanup");
+ _shell_global_destroy_gjs_context (shell_global_get ());
+ g_object_unref (shell_global_get ());
g_object_unref (sender);
return ecode;
void _shell_global_set_plugin (ShellGlobal *global,
MetaPlugin *plugin);
+void _shell_global_destroy_gjs_context (ShellGlobal *global);
+
GjsContext *_shell_global_get_gjs_context (ShellGlobal *global);
gboolean _shell_global_check_xdnd_event (ShellGlobal *global,
{
ShellGlobal *global = SHELL_GLOBAL (object);
- g_object_unref (global->js_context);
+ g_clear_object (&global->js_context);
g_object_unref (global->settings);
the_object = NULL;
return the_object;
}
+/**
+ * _shell_global_destroy_gjs_context: (skip)
+ * @self: global object
+ *
+ * Destroys the GjsContext held by ShellGlobal, in order to break reference
+ * counting cycles. (The GjsContext holds a reference to ShellGlobal because
+ * it's available as window.global inside JS.)
+ */
+void
+_shell_global_destroy_gjs_context (ShellGlobal *self)
+{
+ g_clear_object (&self->js_context);
+}
+
static guint32
get_current_time_maybe_roundtrip (ShellGlobal *global)
{